package com.wsh.controller.sys;

import com.wsh.utils.FileUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/sys/file")
public class MirosFileController {

    @Value("${filePath}")
    private String disPath;

    /**
     * 打包附件下载
     * @param path      路径
     * @param fileName  下载文件名称
     * @param zip       是否压缩
     * @param request
     * @param response
     * @throws Exception
     */
    @PostMapping("/downFile")
    public void downFile(String path, String fileName, Boolean zip, HttpServletRequest request, HttpServletResponse response) throws Exception {
        FileUtil.downloadFile(request, response, path, fileName, zip, disPath);
    }
}
